import variables from '@/style/variables.module.scss'

export const useSettingStore = defineStore(
  'setting',
  () => {
    const settings = reactive({
      theme: variables.theme,
      originalTheme: '',
      showTagsView: true,
      showSidebarLogo: true
    })
    type ISetting = typeof settings
    const changeSetting = <T extends keyof ISetting>({
      key,
      value
    }: {
      key: T
      value: ISetting[T]
    }) => {
      settings[key] = value
    }

    return { settings, changeSetting }
  },
  {
    persist: {
      storage: sessionStorage,
      pick: ['settings']
    }
  }
)
